home *** CD-ROM | disk | FTP | other *** search
- page 56,132
- title INTRACE Display whenever an interrupt type 2 occurs
- .sall
- ;
- ; Program to display the interrupted address whenever an interrupt
- ; of type 2 occurs. This is used to find out where MultiLink is writing
- ; to the IBM Prototype Board.
- ;
- ; If this program seems to have some superfluous code, it's because it
- ; was originally used in tracing disk I/O calls to debug a device
- ; driver...
- ;
-
- ;
- ; Macros
- ;
-
- ;
- ; wto: write message to display. Append cr/lf unless crsup=nocr
- ;
-
- wto macro msg,crsup
- local msgstr,around
-
- jmp around
-
- msgstr db msg
- ifb <crsup>
- db 0DH,0AH
- endif
- db '$'
-
- around: push ax
- push bx
- push si
- push di
- push bp
-
- mov si,offset msgstr
- call putc
-
- pop bp
- pop di
- pop si
- pop bx
- pop ax
-
- endm
-
- prtreg macro rg,msg ; put register rg with message msg on display
-
- push ax
-
- mov ax,rg
- call prtax
- wto msg,nocr
-
- pop ax
- endm
-
-
- ;
- ; Code Segment
- ;
-
- cseg segment para public 'code'
- assume cs:cseg,ds:cseg,ss:cseg,es:nothing
-
- org 100H
- ;
- ; COM program startup
- ;
- cpstart proc far
- jmp near ptr start
- cpstart endp
-
- ;
- ; Local Procedures
- ;
- putc proc near ; write a string to display W/O DOS intervention
- mov bl,7 ; Parameter setup same as for DOS's write-string
- mov bh,0 ; function
- putc1:
- mov al,cs:[si]
- cmp al,'$'
- je putc2
- mov ah,14
- int 10H
- inc si
- jmp putc1
-
- putc2:
- ret
- putc endp
-
- prtnum proc near ; print half a byte on screen
- push ds ; this procedure is used by prtax below
- push cs
- pop ds
- push bx
- mov bx,offset xltab
- xlatb
- mov ah,14
- mov bh,0
- int 10h
- pop bx
- pop ds
- ret
- xltab db '0123456789ABCDEF'
- prtnum endp
-
- prtax proc near ; print contents of ax register on screen
- push cx ; all registers are preserved
- push ax
- mov al,ah
- mov cl,4
- shr al,cl
- call prtnum
- pop ax
- push ax
- mov al,ah
- and al,0Fh
- call prtnum
- pop ax
- push ax
- mov cl,4
- shr al,cl
- call prtnum
- pop ax
- push ax
- and al,0Fh
- call prtnum
- pop ax
- pop cx
- ret
- prtax endp
-
- ;
- ; this routine does the actual display of the interrupted location
- ;
-
- sssav dw ?
- spsav dw ?
- axsav dw ?
-
- lsbottom db 1024 dup (?)
- lstack dw 0
-
- tracer proc near
-
- ;
- ; establish our environment
- ; we turn off ints here for old 8088s with defective microcode
- ; (e.g., mine)
- ;
-
- cli
- mov cs:axsav,ax ; switch stacks
- mov cs:sssav,ss
- mov cs:spsav,sp
- mov ax,cs
- mov ss,ax
- mov sp,offset lstack
- sti
-
- mov ax,cs:axsav ; get ax back
-
- ;
- ; print address to which the RTI will return
- ;
-
- push ax
- push bx
- push es
-
- mov es,cs:sssav
- mov bx,cs:spsav
-
- wto "int2: ",nocr
- prtreg es:2[bx],":"
- prtreg es:[bx]," "
- wto " "
-
- pop es
- pop bx
- pop ax
-
- mov al,20H ; signal EOI
- out 20H,al
- mov ax,cs:axsav
-
- ;
- ; reestablish original environment
- ;
-
- cli ; restore stack
- mov ss,cs:sssav
- mov sp,cs:spsav
- sti
-
- iret
-
- tracer endp
-
- ;
- ; everything below this point will be deleted from memory once the initial
- ; command exits
- ;
-
- start proc near
-
- wto "Installing interrupt trace."
- mov ax,0
- mov es,ax
-
- mov ax,offset tracer
- mov word ptr es:28H,ax
- mov ax,cs
- mov word ptr es:2aH,ax
-
- wto "Enabling interrupt"
-
- mov al,0B8H
- out 21H,al
- mov al,20H
- out 20H,al
-
- wto "Interrupt enabled"
-
- wto "Installation complete; executing TSR."
- mov dx,offset start
- add dx,100H ; a little extra space...
- int 27H
-
- start endp
-
- cseg ends
-
- end cpstart